package com.tiankong.ware.controller;


import com.tiankong.ware.entity.WareSku;
import com.tiankong.ware.service.WareSkuService;
import net.youdi.common.filter.PageFilter;
import net.youdi.common.model.Page;
import net.youdi.common.model.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Set;


/**
 * <p>
 * 商品库存 前端控制器
 * </p>
 *
 * @author scl
 * @since 2021-03-22
 */
@RestController
@RequestMapping("/waresku")
public class WareSkuController {

    @Autowired
    private WareSkuService wareSkuService;

    @GetMapping("list/page")
    public Result listPage(PageFilter filter){
        Page page = wareSkuService.queryPage(filter);
        return Result.ok().setPage(page);

    }
    @PostMapping({"save","update"})
    public Result save(@RequestBody WareSku wareSku){
        wareSkuService.saveOrUpdate(wareSku);
        return Result.ok(wareSku);
    }

    @DeleteMapping("delete")
    public Result delete(@RequestBody Set<Long> ids){
        wareSkuService.removeByIds(ids);
        return Result.ok();
    }
    @GetMapping("info/{id}")
    public Result delete(@PathVariable Long id){
        WareSku wareSku = wareSkuService.getById(id);
        return Result.ok(wareSku);
    }

}
